import 'package:flutter/material.dart';
import 'package:fzcgx_app/common/adapter_utils.dart';
import 'package:fzcgx_app/ui/order/page/order_release_page.dart';
import 'package:fzcgx_app/ui/order/page/order_rob_page.dart';

class OrderPage extends StatefulWidget {
  OrderPage({Key key}) : super(key: key);

  @override
  _OrderPageState createState() => _OrderPageState();
}

class _OrderPageState extends State<OrderPage>
    with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
  TabController _tabController;
  List _titleList = ['我抢到的', '我发布的'];
  List<Widget> _pageList=[OrderRobPage(),OrderReleasePage()];
  @protected
  bool get wantKeepAlive => true;
  @override
  void initState() {
    super.initState();
    _tabController = null;
    _tabController = TabController(
        initialIndex: 0, length: _titleList.length, vsync: this); // 直接传this

    print("---->${_tabController.previousIndex}");

    if (_tabController.indexIsChanging) {
      print("---->indexch");
    }
  }

  @override
  // ignore: must_call_super
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xffF5F5F5),
      body: SafeArea(
          child: Column(
        children: <Widget>[
          SizedBox(height: AdapterUtils.getHeight(10)),
          Container(
            child: TabBar(
              controller: _tabController,
              isScrollable: false,
               indicatorColor: Colors.transparent,
               labelStyle:  TextStyle(
                      color: Color(0xff141F33),
                      fontWeight: FontWeight.bold,
                      fontSize: AdapterUtils.getSp(20)),
                labelColor: Color(0xff141F33), 
                unselectedLabelColor: Color(0xff606B79),
                unselectedLabelStyle: TextStyle(
                        color: Color(0xff606B79),
                        fontWeight: FontWeight.bold,
                        fontSize: AdapterUtils.getSp(16)),     
              tabs: _titleList.map((f) {
                return Tab(text: f,);
              }).toList(),
            ),
          ),
          Expanded(child: TabBarView(
             controller: _tabController,
             children: _pageList,
          )),
            
        ],
      )),
    );
  }
}
